﻿using System;
using System.Collections.Generic;
using System.Data;
namespace BLL.Room
{
   /// <summary>
	/// 业务逻辑类ROOM_LIST 的摘要说明。
	/// </summary>
	public class ROOM_LIST
	{
		private readonly OracleDAL.Room.ROOM_LIST dal=new OracleDAL.Room.ROOM_LIST();
        /// <summary>
        /// 构造函数
        /// </summary>
		public ROOM_LIST()
		{}
		#region  成员方法
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string ROOMID)
		{
			return dal.Exists(ROOMID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Model.Room.ROOM_LIST model)
		{
			dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public void Update(Model.Room.ROOM_LIST model)
		{
			dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public void Delete(string ROOMID)
		{
			
			dal.Delete(ROOMID);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.Room.ROOM_LIST GetModel(string ROOMID)
		{
			
			return dal.GetModel(ROOMID);
		}

        ///// <summary>
        ///// 得到一个对象实体，从缓存中。
        ///// </summary>
        //public Model.Room.ROOM_LIST GetModelByCache(string ROOMID)
        //{
			
        //    string CacheKey = "ROOM_LISTModel-" + ROOMID;
        //    object objModel = LTP.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = dal.GetModel(ROOMID);
        //            if (objModel != null)
        //            {
        //                int ModelCache = LTP.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                LTP.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch{}
        //    }
        //    return (Model.Room.ROOM_LIST)objModel;
        //}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.Room.ROOM_LIST> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.Room.ROOM_LIST> DataTableToList(DataTable dt)
		{
			List<Model.Room.ROOM_LIST> modelList = new List<Model.Room.ROOM_LIST>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.Room.ROOM_LIST model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.Room.ROOM_LIST();
					model.ROOMID=dt.Rows[n]["ROOMID"].ToString();
					model.ROOMNAME=dt.Rows[n]["ROOMNAME"].ToString();
					//model.COLLECTID=dt.Rows[n]["COLLECTID"].ToString();
					model.BELONGAREA=dt.Rows[n]["BELONGAREA"].ToString();
                   // model.BELONGAREANAME = dt.Rows[n]["BELONGAREANAME"].ToString();
					model.REMARK=dt.Rows[n]["REMARK"].ToString();
					model.BACKGROUNDIMAGE=dt.Rows[n]["BACKGROUNDIMAGE"].ToString();
					model.ROOMIMAGE=dt.Rows[n]["ROOMIMAGE"].ToString();
					model.ADDRESS=dt.Rows[n]["ADDRESS"].ToString();
                    if (dt.Rows[n]["LAT"].ToString() != "")
                    {
                        model.LAT = decimal.Parse(dt.Rows[n]["LAT"].ToString());
                    }
                    if (dt.Rows[n]["LNG"].ToString() != "")
                    {
                        model.LNG = decimal.Parse(dt.Rows[n]["LNG"].ToString());
                    }
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}
         /// <summary>
      /// 获取机房列表数据
      /// </summary>
      /// <param name="ID">节点ID</param>
      /// <param name="NODETYPE">节点类型(NODE表示获取区域列表，LEAF获取区域下机房列表)</param>
      /// <returns></returns>
        public DataSet GetRoomList(string ID, string NODETYPE)
        {
          return  dal.GetRoomList(ID, NODETYPE);
        }
		/// <summary>
		/// 获得数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  成员方法
	}
}

